//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package test.集合.斗地主3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;

public class PokerGame {
    private static List<String> poker = new ArrayList();
    private static final int n = 54;
    private static HashMap<String, Integer> score = new HashMap();

    public PokerGame() {
        Collections.shuffle(poker);
        ArrayList<String> bottomCard = new ArrayList();
        ArrayList<String> player1 = new ArrayList();
        ArrayList<String> player2 = new ArrayList();
        ArrayList<String> player3 = new ArrayList();
        int index = 0;

        while(index < 51) {
            player1.add((String)poker.get(index++));
            player2.add((String)poker.get(index++));
            player3.add((String)poker.get(index++));
        }

        Collections.addAll(bottomCard, new String[]{(String)poker.get(53), (String)poker.get(52), (String)poker.get(51)});
        PokerSort(bottomCard);
        PokerSort(player1);
        PokerSort(player2);
        PokerSort(player3);
        LookCards("玩家1: ", player1);
        LookCards("玩家2: ", player2);
        LookCards("玩家3: ", player3);
        LookCards("底牌 : ", bottomCard);
    }

    public static void PokerSort(ArrayList<String> list) {
        Collections.sort(list, new Comparator<String>() {
            public int compare(String o1, String o2) {
                String o1Color = o1.substring(0, 1);
                int o1Number = PokerGame.PokerNumber(o1);
                String o2Color = o2.substring(0, 1);
                int o2Number = PokerGame.PokerNumber(o2);
                int i = o1Number - o2Number;
                return i == 0 ? o2Color.compareTo(o1Color) : i;
            }
        });
    }

    public static int PokerNumber(String s) {
        String number = s.substring(1);
        return score.containsKey(number) ? (Integer)score.get(number) : Integer.parseInt(number);
    }

    public static void LookCards(String name, List<String> cords) {
        System.out.print(name + " ");

        for(String s : cords) {
            System.out.print(s + " ");
        }

        System.out.println();
    }

    static {
        String[] colors = new String[]{"♥", "♦", "♠", "♣"};
        String[] nums = new String[]{"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};

        for(String color : colors) {
            for(String num : nums) {
                poker.add(color + num);
            }
        }

        poker.add(" 小王");
        poker.add(" 大王");
        score.put("J", 11);
        score.put("Q", 12);
        score.put("K", 13);
        score.put("A", 14);
        score.put("2", 15);
        score.put("大王", 50);
        score.put("小王", 100);
    }
}
